/* String */
String.prototype.startsWith = function (text) {
    return this.indexOf(text) == 0;
};

String.prototype.format = function () {
    var value = this;
    for (var i = 0; i < arguments.length; i++) {
        value = value.replace('{' + i + '}', arguments[i]);
    }
    return value;
};

String.prototype.contains = function (text) {
    return this.indexOf(text) >= 0;
};

/* Date */
Date.prototype.format = function (format) {
    return format.replace('yyyy', this.getFullYear())
        .replace('MM', this.getMonth() + 1)
        .replace('dd', this.getDate())
        .replace('HH', this.getHours())
        .replace('mm', this.getMinutes())
        .replace('ss', this.getSeconds());
};

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,'');
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/,'');
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,'');
}

/* TypeUtil */
function TypeUtil() { }

TypeUtil.isString = function (value) {
    return (value instanceof String) || (typeof value == 'string');
};
TypeUtil.isArray = function (value) {
    return value instanceof Array;
};
TypeUtil.isNumeric = function (value) {
    return (typeof value == 'numeric');
};